package com.bank.user.service.impl;

import com.bank.model.entity.UserRole;
import com.bank.user.service.UserRoleService;
import com.bank.user.util.MapperFactory;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author callumEm
 * @version 1.0
 * @create 2023/4/21 10:17
 */
@Service
public class UserRoleServiceImpl implements UserRoleService {
    @Autowired
    MapperFactory mapperFactory;

    @Override
    public UserRole queryByRoleId(Long roleId) {
        QueryWrapper<UserRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role_id",roleId);
        return mapperFactory.getUserRoleMapper().selectOne(queryWrapper);
    }

    @Override
    public UserRole queryByUserId(Long userId) {
        QueryWrapper<UserRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        return mapperFactory.getUserRoleMapper().selectOne(queryWrapper);
    }
}
